package com.cyy.common.config.jackson;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;

import java.time.LocalDate;
import java.time.LocalDateTime;

@Configuration
public class MyJacksonConfig {

    @Autowired
    public void appConfigureObjectMapper(ObjectMapper objectMapper) {
        SimpleModule module = new SimpleModule();

        module.addDeserializer(LocalDateTime.class, new MyLocalDateTimeDeserializer());
        module.addDeserializer(LocalDate.class, new MyLocalDateDeserializer());

        objectMapper.registerModule(module);
    }

}
